<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加物业公司</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="layui/layui.js"></script>
</head>
<body>
<form class="layui-form" action="/addProperty" method="post" style="margin-top: 20px">
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:200px;font-size: 23px;font-weight: bold;">物业名称</label>
        <div class="layui-input-block" >
            <input type="text" style="height: 30px;width: 700px;font-size: 23px;" name="propertyname" required  lay-verify="required" placeholder="请输入物业名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:200px;font-size: 23px;font-weight: bold"  >物业编码</label>
        <div class="layui-input-inline">
            <input type="text" maxlength="3" style="height: 30px;width: 700px;font-size: 23px;" name="propertycode" required lay-verify="required" placeholder="请输入物业编码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:200px;font-size: 23px;font-weight: bold">负责人</label>
        <div class="layui-input-inline">
            <input type="text" style="height: 30px;width: 700px;font-size: 23px;" name="director" required lay-verify="required" placeholder="请输入负责人姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:200px;font-size: 23px;font-weight: bold">联系方式</label>
        <div class="layui-input-inline">
            <input maxlength="11"  type="text" style="height: 30px;width: 700px;font-size: 23px;" name="telphone" required lay-verify="required" placeholder="请输入联系方式" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:200px;font-size: 23px;font-weight: bold">登录密码</label>
        <div class="layui-input-inline">
            <input type="password" maxlength="18"  style="height: 30px;width: 700px;font-size: 23px;" name="loginpassword" required lay-verify="required" placeholder="请输入物业的登录密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:200px;font-size: 23px;font-weight: bold">物业地址</label>
        <div class="layui-input-inline">
            <input type="text" style="height: 30px;width: 700px;font-size: 23px;" name="propertyaddress" required lay-verify="required" placeholder="请输入物业地址" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label" style="width:200px;font-size: 23px;font-weight: bold">物业简介</label>
        <div class="layui-input-block">
            <textarea name="propertyindroduce" style="height: 90px;width: 700px;font-size: 23px;" placeholder="请输入物业简介" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width:200px;font-size: 25px;font-weight: bold;line-height: 200px">
            <button type="button" name="file" lay-submit="uploadimg" class="layui-btn" id="test1">
                上传logo
            </button>
        </label>

        <div class="layui-input-inline" style="border: lightgray solid 1px;width: 200px;height: 200px">
            <img alt="" id="iamgepath" style="width: auto;height: auto;  max-width: 100%;  max-height: 100%;">
        </div>
        <input type="text" id="imgpath" name="propertylogo" style="display: none" value="123">

    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" id="but" lay-submit lay-filter="formDemo">立即添加</button>
            <button type="reset" id="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

</body>

<script>
    var $=layui.$;

    $("#reset").click(function () {
        $("#iamgepath").attr("src","");
    });

    layui.use('upload', function(){
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            ,accept:"images"
            ,url: '/addimage' //上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#iamgepath').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //上传完毕回调
                console.log(res);
                console.log("上传图片");
                $("#iamgepath").attr("src","/upload/"+res.data.src);
                $("#imgpath").val(res.data.src);
                path=$("#imgpath").val();
                console.log("path=="+path);
            }
            ,error: function(){
                //请求异常回调
                console.log("上传失败");
            }
        });

    });

    layui.use('form', function(){
        var form = layui.form;

        form.on('submit(iamgepath)',function(data){
            return false;
        });
    });

</script>
</html>